<?php

if (!is_null($_GET["key"]) && $_GET["key"] != "") {
	$key = $_GET["key"];
} else {
	exit("请先填写key");
}

if (!is_null($_GET["value"])) {
	$value = $_GET["value"];
} else {
	$value = "";
}

if (!is_null($_GET["option"]) && $_GET["option"] != "") {
	$option = $_GET["option"];
} else {
	exit("请填写option");
}

$db = 'mymessageboard';
$host = "localhost";
$user = 'root';
$password = 'root';

// 连接数据库
$con = mysqli_connect($host, $user, $password, $db);
if ($con) {
	echo "连接数据库成功!<br>";
} else {
	echo "连接数据库失败 : " . mysqli_error() . "<br>";
}

// 删除
// $sql = "delete from Persons where id = 2";

// $ret = mysqli_query($con, $sql);
// if ($ret) {
// 	echo "删除成功<br>";
// } else {
// 	echo "删除失败" . mysqli_error() . "<br>";
// }

// 修改数据
$sql = "update Persons SET " . $key . " = '" . $value . "' where " . $option;
$ret = mysqli_query($con, $sql);
if ($ret) {
	echo "更新成功<br>";
} else {
	echo "更新失败" . mysqli_error() . "<br>";
}